/**
 * 将时间戳转换为时间格式
 * @param {*} time 时间戳
 * @param {boolean} isTime 是否只显示年月日
 * @returns
 */
const getDate = (time, isTime = false) => {
  const date = new Date(time);
  const Y = date.getFullYear() + "-";
  const M =
    (date.getMonth() + 1 < 10
      ? "0" + (date.getMonth() + 1)
      : date.getMonth() + 1) + "-";
  const D = date.getDate() + " ";
  const h = date.getHours() + ":";
  const m = date.getMinutes() + ":";
  const s = date.getSeconds();
  if (!isTime) {
    return Y + M + D + h + m + s;
  } else {
    return Y + M + D;
  }
};

export default getDate;
